<?php
require_once BACKGROUND_COMMON_ACTION_SERVICE_DIR . '/default.php';

class background_index_login_captcha_action_service extends background_default_common_action_service
{
    protected static $_instance;

    public static function get_instance()
    {
        if (null === self::$_instance) {
            self::$_instance = new self();
        }

        return self::$_instance;
    }


    protected function _current_page_process()
    {
        $captcha_handler = wwy_resource_container::get_captcha_handler();
        
        //生成验证码【字符串】
        $code = $captcha_handler->generate_code();
        $_SESSION['admin_login_captcha'] = $code;
        
        //生成并【输出】图片
        @ob_end_clean(); //清除之前出现的多余输入
        $font_path = PROJECT_ROOT_PATH . '/public/module/common/css/fonts/SIMLI.TTF';
        
        $captcha_handler->generate_image($font_path, $code);
         
        wwy_action::$data['admin_login_captcha'] = $code;
    }
}